package com.example.myapplication1.ui.order;

import java.util.Date;
import java.util.List;

public class Order {
    private String orderNumber;
    private Date orderTime;
    private List<OrderItem> items;
    private double totalAmount;

    public Order(String orderNumber, Date orderTime, List<OrderItem> items, double totalAmount) {
        this.orderNumber = orderNumber;
        this.orderTime = orderTime;
        this.items = items;
        this.totalAmount = totalAmount;
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public List<OrderItem> getItems() {
        return items;
    }

    public double getTotalAmount() {
        return totalAmount;
    }

    public String getItemsDescription() {
        StringBuilder description = new StringBuilder();
        for (int i = 0; i < items.size(); i++) {
            OrderItem item = items.get(i);
            description.append(item.getProductName())
                    .append(" x")
                    .append(item.getQuantity());
            if (i < items.size() - 1) {
                description.append("\n");
            }
        }
        return description.toString();
    }

    public static class OrderItem {
        private String productName;
        private int quantity;
        private double price;

        public OrderItem(String productName, int quantity, double price) {
            this.productName = productName;
            this.quantity = quantity;
            this.price = price;
        }

        public String getProductName() {
            return productName;
        }

        public int getQuantity() {
            return quantity;
        }

        public double getPrice() {
            return price;
        }
    }
} 